package cn.cvs.service.impl;

import cn.cvs.dao.SupplierMapper;
import cn.cvs.pojo.Supplier;
import cn.cvs.service.SysSupplierService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Auther: zwt
 * @Date: 2021/11/14 - 11 - 14 - 18:22
 * @Description: cn.cvs.service.impl
 * @version: 1.0
 */
@Service
public class SysSupplierServiceImpl implements SysSupplierService {
    @Resource
    SupplierMapper supplierMapper;

    @Override
    public List<Supplier> queryChoose(String supCode, String supName) {
        List<Supplier> suppliers = supplierMapper.queryChoose(supCode, supName);
        return suppliers;
    }

    @Override
    public List<Supplier> querySupplier(String supCode, String supName, Integer pageNo, Integer pageSize) {
        List<Supplier> suppliers = supplierMapper.queryByPage(supCode, supName, (pageNo - 1) * pageSize, pageSize);
        return suppliers;
    }

    @Override
    public int queryCount(String supCode, String supName) {
        int count = supplierMapper.queryCount(supCode, supName);
        return count;
    }

    @Transactional(rollbackFor = {Exception.class})
    @Override
    public int addSupplier(Supplier supplier) {
        int add = supplierMapper.add(supplier);
        return add;
    }

    @Override
    public Supplier queryById(Integer id) {
        Supplier supplier = supplierMapper.queryById(id);
        return supplier;
    }

    @Override
    public int updateSupplier(Supplier supplier) {
        int update = supplierMapper.update(supplier);
        return update;
    }

    @Override
    public int delete(Integer id) {
        int delete = supplierMapper.delete(id);
        return delete;
    }
}
